package thread;

public class ThreadGroupTest {

    public static void main(String[] args) {
        Thread t1=new Thread();
        //线程默认规组在当前线程的组中
        System.out.println(t1.getThreadGroup().getName());

        ThreadGroup threadGroup=new ThreadGroup("A组");


        Thread t2=new Thread(threadGroup,new Runnable() {
            @Override
            public void run() {
                Thread t22 = new Thread();
                System.out.println("t22所在线程组"+t22.getThreadGroup().getName());
                System.out.println("t22上级所在线程组"+t22.getThreadGroup().getParent().getName());
            }
        });
        t2.start();
        System.out.println("t2所在线程组"+t2.getThreadGroup().getName());


        //system 线程组是最高级别线程组
        System.out.println("main上级所在线程组"+Thread.currentThread().getThreadGroup().getParent().getName());

    }


}
